# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>

_hkgname=ed25519
pkgname=haskell-ed25519
pkgver=0.0.5.0
pkgrel=24
pkgdesc="Ed25519 cryptographic signatures"
url="http://thoughtpolice.github.com/hs-ed25519"
license=("MIT")
arch=('loong64' 'x86_64')
depends=('ghc-libs')
makedepends=('ghc')
source=("https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz")
sha512sums=('cd2bb28de905c6d659f80f15e82970a9634c959432c73b6fd3b10ebca42a1ce734429e7ac861d0ab328904d99651a6d2fcaaf4d74ab75a3c0be68607e8f54ce9')

prepare() {
    sed -i 's/ghc-prim    >= 0.1 && < 0.5,/ghc-prim    >= 0.1,/' ${_hkgname}-${pkgver}/${_hkgname}.cabal
}

build() {
    cd $_hkgname-$pkgver

    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
            -f-test-properties -f-test-hlint -f-test-doctests -fno-donna
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver

    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 "LICENSE.txt" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.txt"
    rm -f "${pkgdir}/usr/share/doc/${pkgname}/LICENSE.txt"
}
